<template>
	<uni-card :is-shadow="false" is-full>
		<text class="uni-h6 cardcss">
			{{orderData.communityName}}-{{orderData.buildingNumber}}-{{orderData.floorNumber}} -{{orderData.roomNumber}}
			号房,宽带号为 {{orderData.broadbandNumber}},目前宽带状态为 {{broadStatusTransChar}}, 目前正{{broadStatusTransText}}
		</text>
		<view class="status">
			<text class="createtime fl">{{DataTransfer}}</text>
			<text class="close fr" v-if="charAssert">状态:宽带已关停</text>
			<text class="open fr" v-if="!charAssert">状态:宽带已开通</text>
		</view>
	</uni-card>
</template>

<script>
	export default {
		name: 'OrderCard',
		props: ['data'],
		data() {
			return {
				datas: this.data,
				status: true,
				orderData: {
					dataId: this.data.dataId,
					communityName: this.data.communityName,
					buildingNumber: this.data.buildingNumber,
					floorNumber: this.data.floorNumber,
					roomNumber: this.data.roomNumber,
					broadbandNumber: this.data.broadbandNumber,
					broadbandStatus: this.data.broadbandStatus,
					userId: this.data.userId,
					workOrderStatus: this.data.workOrderStatus,
					workOrderTime: this.data.workOrderTime,
					creationTime: this.data.creationTime
				}
			}
		},
		computed: {
			/**
			 * 
			 */
			DataTransfer() {
				var date = new Date(this.$data.orderData.creationTime);
				// 获取年、月和日
				var year = date.getFullYear();
				var month = date.getMonth() + 1; // 月份从 0 开始，需要加 1
				var day = date.getDate();
				// 将月份和日期转换为两位数格式
				month = month < 10 ? '0' + month : month;
				day = day < 10 ? '0' + day : day;
				// 构造所需的日期格式
				var formattedDate = year + '-' + month + '-' + day;
				return formattedDate
			},
			/**
			 * 
			 */
			charAssert() {
				switch (this.orderData.broadbandStatus) {
					case "0":
						return true;
					case "1":
						return false;
				}
			},
			/**
			 * 
			 */
			broadStatusTransChar() {
				switch (this.$data.orderData.broadbandStatus) {
					case "0":
						return '未开通';
					case "1":
						return '已开通';
				}
			},
			/**
			 * 
			 */
			broadStatusTransText() {
				switch (this.$data.orderData.broadbandStatus) {
					case "0":
						return '在开通';
					case "1":
						return '在关闭';
				}
			}
		},
		// 挂载钩子函数
		mounted() {}
	}
</script>

<style>
	.status {
		margin-top: 20px;
		display: block;
	}

	.open {
		color: royalblue;
	}

	.close {
		color: darkred;
	}

	.fr {
		float: right;
	}

	.fl {
		float: left;
	}

	.cardcss {
		margin-bottom: 10px;
	}
</style>